package main

import (
	"encoding/json"
	"fmt"
)

type User struct {
	UserName string  `json:"username"`
	NickName string  `json:"nickname"`
	Age int  `json:"age"`
	Vip bool  `json:"vip"`
}

func main() {
	var jsonStr = `{
		"username": "Kara",
		"nickname": "Supergirl",
		"age": 20,
		"vip": false
		}`
	var jsonByte = []byte(jsonStr)
	var u2 User
	if err := json.Unmarshal(jsonByte, &u2); err == nil {
		fmt.Println(u2)
	} else {
		fmt.Println("ERROR:", err)
	}
}